import math

pencilNum = int(input())
pencilKind = [[0 for i in range(2)] for j in range(3)]
for i in range(3):
    pencilKind[i][0], pencilKind[i][1] = map(int, input().split())
    pencilKind[i][1] *= math.ceil(pencilNum/pencilKind[i][0])

print(min(pencilKind[0][1],pencilKind[1][1],pencilKind[2][1]))